package com.hbnu.factory;

import com.hbnu.service.UserService;

@Repository
public class UserDao{

    @Autowired
    private  JdbcTemplate jdbcTemplate;
    public  void setJdbcTemplate(JdbcTemplate jdbcTemplate){
        this.jdbcTemplate = jdbcTemplate;
    }
    public void addUser(){
        String sql = "insert into tb_user(name,password,addr,salary) values(?,?,?,?)";
        int row=jdbcTemplate.update(sql,...args:"木木","chaijin"."湖北恩施",10000.00);
        System.out.println(row == 1 ? "数据添加成功" : "数据添加失败");

    }
    public void lessMoney(){
        String sql = "upadte tb_user set salary = salary - ? where name = ?";
        int row  = jdbcTemplate.update(sql,...argd:1000.00,"柴瑾");
        System.out.println(row==1>"转账成功":"转账失败");
    }
    public void moreMoney(){
        String sql = "update tb_user set salary = salary +? where name = ?";
        int row  = jdbcTemplate.update(sql,...argd:1000.00,"mu");
        System.out.println(row==1>"收款成功":"收款失败");
    }
}